home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 5 / BBS in a Box -Volume V (BBS in a Box) (April 1992).iso / Files / Tele / R / RR10Translator < prev    next >
Encoding:
Text File  |  1987-09-13  |  6.5 KB  |  346 lines  |  [TEXT/MSWD]

  1. ( ROUTINE:    Fix for RR10
  2. (
  3. ( PURPOSE:    Attempts to automatically convert Red Ryder procedures created
  4. (        for 9.X to the new 10.0 syntax.  Specifically does the
  5. (        following:
  6. (
  7. (        1. Saves original file with .OLD extension to file name
  8. (        2. Converts all comments to labels (simplistic but effective)
  9. (        3. ESC becomes ALT
  10. (        4. DEL becomes DELKEY
  11. (        5. MENUDOES reformatted but left incomplete (sorry)
  12. (        6. MENU OFF becomes MENUOFF
  13. (        7. Converts all variables to new style (e.g. ~9 becomes Z$)
  14. (        8. Compiles result unless problem #5 above encounterd
  15. (
  16. ( PROBLEMS:    The following are known limitations of this procedure:
  17. (
  18. (        1. ESC, DEL, MENUDOES, and MENU OFF are not converted if not
  19. (           first command in line (i.e. column 1).  Otherwise I might
  20. (           convert lines such as: COPYINTO A$,ALTERNATIVE
  21. (        2. Converting comments into labels might overflow label limits.
  22. (           Since most of my procedures are small, this is not expected.
  23. (
  24. ( WARNNGS:    Do not run on an already converted file.
  25. (
  26. ( LICENSE:    This procedure is not in the public domain, but may be freely 
  27. (        used for non-commercial purposes by all paid & registered users
  28. (        of Freesoft's Red Ryder 10.0 terminal emulation program.  It
  29. (        may not be sold nor used as incentive to buy any other product.
  30. (        This procedure is supplied for use AS IS, and there are no
  31. (        guarantees of correctness or usability for any particular 
  32. (        purpose.  USE AT YOUR OWN RISK.
  33. (
  34. ( AUTHOR:    David C. Black, 311 Blackberry Drive, Austin, Tx 78745-6546
  35. (        COPYRIGHT ©1987 by David Black, all rights reserved.
  36. (
  37. ( NOTE:        If you should find ways to improve this procedure, I would
  38. (        appreciate hearing from you about the modifications.  If you
  39. (        do modify this procedure, please make appropriate additions to
  40. (        the history below, and indicate your name & address before
  41. (        supplying copies of your 'new & improved' version to others.  I
  42. (        can respond to my own code, but I cannot respond support
  43. (        others.
  44. (
  45. ( MODIFIED WHO VER REASON
  46. ( -------- --- --- ------
  47. ( 09/06/87 DCB 1.0 Original
  48. (**********************************************************************
  49.  
  50. ( *** Initializations ***
  51. ERASE X$
  52. COPYINTO Y$,Procedure to fix Red Ryder PROCs for version 10.0
  53. COPYINTO Z$,COPYRIGHT 1987 by David Black, all rights reserved.
  54. QUERY2
  55. COPYINTO @0,Updating Red Ryder PROCs for version 10.0
  56. ERASE @1
  57. ERASE @2
  58. @ ON
  59. WATCH ON
  60. COPYINTO D$,$
  61. COPYINTO P$,%
  62. LET EQUAL C%,0
  63. LET EQUAL M%,0
  64.  
  65. ( *** Open up files ***
  66. COPYINTO @2,Select file to update:
  67. SHOW@
  68. BELL
  69. GETSELECT TEXT
  70. GETFILE O$
  71. ERASE @2
  72. SHOW@
  73. IF NO JUMPTO ABORT
  74. WATCH ON
  75. COPYINTO I$,O$
  76. CONCAT I$,.OLD
  77. RENAME O$,I$
  78. USEROPENI 1,I$
  79. USEROPENO 2,O$
  80. COPYINTO Z$,Renamed original to '
  81. CONCAT Z$,I$
  82. CONCAT Z$,'...
  83. QUERY5
  84.  
  85. ( *** Loop until end-of-file encountered ***
  86. :LOOP
  87. USERREAD 1,L$
  88. IF ERROR JUMPTO EXITLOOP
  89. GOSUB SANITY
  90.  
  91. ( *** Skip empty lines
  92. EMPTY L$
  93. IF YES JUMPTO WRITE_RESULT
  94.  
  95. ( *** Convert comments to labels ***
  96. INSTR L%,L$,1,(
  97. TEST L% = 1
  98. IF NO JUMPTO END_COMMENT
  99. COPYINTO T$,:
  100. CONCAT T$,L$
  101. COPYINTO L$,T$
  102. JUMPTO WRITE_RESULT
  103. :END_COMMENT
  104.  
  105. ( *** Convert ESC to ALT ***
  106. INSTR L%,L$,1,ESC 
  107. TEST L% = 1
  108. IF NO JUMPTO END_ALT
  109. REPLACE$ L$,3,1,ALT
  110. :END_ALT
  111.  
  112. ( *** Convert DEL to DELKEY ***
  113. INSTR L%,L$,1,DEL 
  114. TEST L% = 1
  115. IF NO JUMPTO END_DELKEY
  116. REPLACE$ L$,3,1,KEY
  117. COPYINTO T$,DEL
  118. CONCAT T$,L$
  119. COPYINTO L$,T$
  120. :END_DELKEY
  121.  
  122. ( *** Reformat MENUDOES commands ***
  123. INSTR L%,L$,1,MENUDOES
  124. TEST L% = 1
  125. IF NO JUMPTO END_MENUDOES
  126. ADD M%,1
  127. COPYINTO T$,L$
  128. COPYINTO L$,MENUDOES 
  129. MID$ U$,9,2,T$
  130. CONCAT L$,T$
  131. CONCAT L$,,__Replace_
  132. MID$ U$,12,2,T$
  133. CONCAT L$,T$
  134. CONCAT L$,_with_action_from_macro_set__
  135. :END_MENUDOES
  136.  
  137. ( *** Convert MENU OFF to MENUOFF ***
  138. INSTR L%,L$,1,MENU OFF
  139. TEST L% = 1
  140. IF NO JUMPTO END_MENUOFF
  141. COPYINTO L$,MENUOFF
  142. JUMPTO WRITE_RESULT
  143. :END_MENUOFF
  144.  
  145. ( *** Convert variables to new equivalents ***
  146. INSTR L%,L$,1,~9
  147. TEST L% = 0
  148. IF YES JUMPTO END_~9
  149. REPLACE$ L$,1,L%,Z
  150. ADD L%,1
  151. REPLACE$ L$,1,L%,D$
  152. :END_~9
  153.  
  154. INSTR L%,L$,1,~8
  155. TEST L% = 0
  156. IF YES JUMPTO END_~8
  157. REPLACE$ L$,1,L%,Y
  158. ADD L%,1
  159. REPLACE$ L$,1,L%,D$
  160. :END_~8
  161.  
  162. INSTR L%,L$,1,~7
  163. TEST L% = 0
  164. IF YES JUMPTO END_~7
  165. REPLACE$ L$,1,L%,X
  166. ADD L%,1
  167. REPLACE$ L$,1,L%,D$
  168. :END_~7
  169.  
  170. INSTR L%,L$,1,~6
  171. TEST L% = 0
  172. IF YES JUMPTO END_~6
  173. REPLACE$ L$,1,L%,W
  174. ADD L%,1
  175. REPLACE$ L$,1,L%,D$
  176. :END_~6
  177.  
  178. INSTR L%,L$,1,~5
  179. TEST L% = 0
  180. IF YES JUMPTO END_~5
  181. REPLACE$ L$,1,L%,V
  182. ADD L%,1
  183. REPLACE$ L$,1,L%,D$
  184. :END_~5
  185.  
  186. INSTR L%,L$,1,~4
  187. TEST L% = 0
  188. IF YES JUMPTO END_~4
  189. REPLACE$ L$,1,L%,U
  190. ADD L%,1
  191. REPLACE$ L$,1,L%,D$
  192. :END_~4
  193.  
  194. INSTR L%,L$,1,~3
  195. TEST L% = 0
  196. IF YES JUMPTO END_~3
  197. REPLACE$ L$,1,L%,T
  198. ADD L%,1
  199. REPLACE$ L$,1,L%,D$
  200. :END_~3
  201.  
  202. INSTR L%,L$,1,~2
  203. TEST L% = 0
  204. IF YES JUMPTO END_~2
  205. REPLACE$ L$,1,L%,S
  206. ADD L%,1
  207. REPLACE$ L$,1,L%,D$
  208. :END_~2
  209.  
  210. INSTR L%,L$,1,~1
  211. TEST L% = 0
  212. IF YES JUMPTO END_~1
  213. REPLACE$ L$,1,L%,R
  214. ADD L%,1
  215. REPLACE$ L$,1,L%,D$
  216. :END_~1
  217.  
  218. INSTR L%,L$,1,~0
  219. TEST L% = 0
  220. IF YES JUMPTO END_~0
  221. REPLACE$ L$,1,L%,Q
  222. ADD L%,1
  223. REPLACE$ L$,1,L%,D$
  224. :END_~0
  225.  
  226. INSTR L%,L$,1,`9
  227. TEST L% = 0
  228. IF YES JUMPTO END_`9
  229. REPLACE$ L$,1,L%,Z
  230. ADD L%,1
  231. REPLACE$ L$,1,L%,P$
  232. :END_`9
  233.  
  234. INSTR L%,L$,1,`8
  235. TEST L% = 0
  236. IF YES JUMPTO END_`8
  237. REPLACE$ L$,1,L%,Y
  238. ADD L%,1
  239. REPLACE$ L$,1,L%,P$
  240. :END_`8
  241.  
  242. INSTR L%,L$,1,`7
  243. TEST L% = 0
  244. IF YES JUMPTO END_`7
  245. REPLACE$ L$,1,L%,X
  246. ADD L%,1
  247. REPLACE$ L$,1,L%,P$
  248. :END_`7
  249.  
  250. INSTR L%,L$,1,`6
  251. TEST L% = 0
  252. IF YES JUMPTO END_`6
  253. REPLACE$ L$,1,L%,W
  254. ADD L%,1
  255. REPLACE$ L$,1,L%,P$
  256. :END_`6
  257.  
  258. INSTR L%,L$,1,`5
  259. TEST L% = 0
  260. IF YES JUMPTO END_`5
  261. REPLACE$ L$,1,L%,V
  262. ADD L%,1
  263. REPLACE$ L$,1,L%,P$
  264. :END_`5
  265.  
  266. INSTR L%,L$,1,`4
  267. TEST L% = 0
  268. IF YES JUMPTO END_`4
  269. REPLACE$ L$,1,L%,U
  270. ADD L%,1
  271. REPLACE$ L$,1,L%,P$
  272. :END_`4
  273.  
  274. INSTR L%,L$,1,`3
  275. TEST L% = 0
  276. IF YES JUMPTO END_`3
  277. REPLACE$ L$,1,L%,T
  278. ADD L%,1
  279. REPLACE$ L$,1,L%,P$
  280. :END_`3
  281.  
  282. INSTR L%,L$,1,`2
  283. TEST L% = 0
  284. IF YES JUMPTO END_`2
  285. REPLACE$ L$,1,L%,S
  286. ADD L%,1
  287. REPLACE$ L$,1,L%,P$
  288. :END_`2
  289.  
  290. INSTR L%,L$,1,`1
  291. TEST L% = 0
  292. IF YES JUMPTO END_`1
  293. REPLACE$ L$,1,L%,R
  294. ADD L%,1
  295. REPLACE$ L$,1,L%,P$
  296. :END_`1
  297.  
  298. INSTR L%,L$,1,`0
  299. TEST L% = 0
  300. IF YES JUMPTO END_`0
  301. REPLACE$ L$,1,L%,Q
  302. ADD L%,1
  303. REPLACE$ L$,1,L%,P$
  304. :END_`0
  305.  
  306. :WRITE_RESULT
  307. USERWRITE 2,L$
  308. USERWRCR 2
  309. JUMPTO LOOP
  310. :EXITLOOP
  311.  
  312. ( *** Close up files and compile (if possible)
  313. USERCLOSE 1
  314. USERCLOSE 2
  315. TEST M% > 0
  316. IF YES JUMPTO MENUDOES_PROBLEM
  317. COMPILE LOUD O$
  318. END
  319.  
  320. :MENUDOES_PROBLEM
  321. COPYINTO X$,This procedure contains 
  322. NUMTOSTRING M%,M$
  323. CONCAT X$,M$
  324. CONCAT X$, MENUDOES commands that I am unable to
  325. COPYINTO Y$,completely translate. Please edit them, and then compile.
  326. COPYINTO Z$,Sorry for the inconvenience...talk to Scott about this one.
  327. QUERY2
  328. END
  329.  
  330. :ABORT
  331. @ OFF
  332. END
  333.  
  334. :SANITY
  335. (
  336. ( PURPOSE:    Notify the user of progress...slow though it may be...
  337. (
  338. ADD C%,1
  339. NUMTOSTRING C%,C$
  340. COPYINTO @1,Processing line #
  341. CONCAT @1,C$
  342. CONCAT @1,...
  343. SHOW@
  344. RETURN
  345.  
  346.